package client;

// Screen.java
// Represents the screen of the ATM

import shared.BalanceData;
import shared.CollectionData;
import shared.TransactionData;

/**
 * class Display handles messages printed out on the screen
 * 
 * @author Rasmus Stjerne, Joachim Lindholm, Daniel Gramstrup, Pamela Pedersen
 */
public class Display {
	/**
	 * displays a message without a carriage return
	 * 
	 * @param message
	 *            the message to be displayed
	 */
	public void displayMessage(String message) {
		System.out.print(message);
	}

	/**
	 * display a message with a carriage return
	 * 
	 * @param message
	 *            the message to be displayed
	 */
	public void displayMessageLine(String message) {
		System.out.println(message);
	}

	/**
	 * display a CC amount
	 * 
	 * @param amount
	 *            the amount to displayed
	 */
	public void displayCCAmount(double amount) {
		System.out.printf("CC %,.2f", amount);
	}

	/**
	 * displays the Spend sub menu
	 * 
	 * @param number
	 *            corresponds to the number to choose
	 * @param amount
	 *            corresponds to the cost
	 * @param description
	 *            informs the use about the activity
	 */
	public void displaySpendLine(int number, double amount, String description) {
		System.out.printf("%d  %,.2f\t%s\n", number, amount, description);
	}

	/**
	 * displays pending transactions
	 * 
	 * @param cd
	 *            the data to be displayed
	 */
	public void displayTransactions(CollectionData cd) {
		for (int i = 1; i <= cd.pendingTransactions.size(); i++) {
			TransactionData td = cd.pendingTransactions.get(i - 1);
			System.err.println(i + " - " + td.name + " (" + td.sender
					+ ")\tAmount: " + td.transferAmount);
		}
	}

	/**
	 * display an error message
	 * 
	 * @param message
	 *            the message to be displayed
	 */
	public void displayErrorMessage(String message) {
		System.err.println(message);
	}

	/**
	 * displays balance - formattet
	 * 
	 * @param bd
	 *            the data to be displayed
	 */
	public void displayBalance(BalanceData bd) {
		System.out.println("\nBalance Information:");
		System.out.printf("\nAvailable balance: %10.2f CC", bd.balance);
		System.out.printf("\nPending balance: %12.2f CC", bd.pendingBalance);
		System.out.printf("\nTotal balance: %14.2f CC", bd.totalBalance);
		System.out.println("");
	}
}